package com.acxy.test.controller;

import com.acxy.ants.resful.annotation.API;
import com.acxy.ants.resful.annotation.Controller;
import com.acxy.ants.resful.annotation.GET;
import com.acxy.ants.resful.annotation.POST;
import com.acxy.test.entity.Test;

import javax.servlet.http.HttpServletRequest;

/**
 * @author MrShun
 * @version 1.0
 * @Date 2017-04-26
 */
@Controller("user")
public class IndexController {

    @POST("test1/{name}")
    public Object index(String name
            , Integer age, Test test) {
        System.out.println(name + " is " + age + ", " + test);
        return null;
    }

    @POST("test2/* ")
    public Integer index2(String name, Integer age) {
        System.out.println(name + " is " + age);
        return 0;
    }

    @POST("test**")
    public void index6(String name, Integer age) {
        System.out.println(name + " is " + age);
    }


    @GET({"/demo", "test*"})
    public String index3() {
        System.out.println();
        return "ok";
    }

    @API("/test/aa")
    public String index8() {
        System.out.println("调用API");
        return "ok";
    }

    @POST("/test/a?")
    public String index5(String name, Integer age) {
        System.out.println(name + " is " + age);
        return "ok";
    }

    @POST("/{name:\\w+}-{age:\\d+}")
    public String index4(String name, Integer age) {
        System.out.println(name + " is " + age);
        return "ok";
    }

    public Integer query(HttpServletRequest request, String name, Integer age) {
        System.out.println("request:" + request.getQueryString());
        System.out.println("执行 query 方法! 参数[" + name + "," + age + "]");
        return 0;
    }

    public String add() {
        System.out.println("执行 add 方法!");
        return "query";
    }

    public void edit() {
        System.out.println("执行 edit 方法!");
    }
}
